home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 3 / ACE CD 3.iso / files / utils / aplay200.lha / APlayer / Files / Developer.lha / Examples / LibraryStartup.S < prev   
Text File  |  1995-12-23  |  4KB  |  185 lines

  1. ; $VER: xx.library 1.0
  2. ;
  3.  
  4.     INCDIR    "Includes3.0:Include3.0/"
  5.     INCLUDE    "Exec/Types.i"
  6.     INCLUDE    "Own/SystemBases.i"
  7.     INCLUDE    "Own/SystemStructures.i"
  8.     INCLUDE    "Own/SystemOffsets.i"
  9.     INCLUDE    "Own/AccessiblePlayer.i"
  10.  
  11.  
  12. VERSION        =    1
  13. REVISION    =    0
  14.  
  15. TRUE        =    -1
  16. FALSE        =    0
  17.  
  18. ; Library Data
  19.  
  20. LN_Name        =    10
  21. LN_Type        =    8
  22. NT_Library    =    9
  23.  
  24. LIBB_Summing    =    0
  25. LIBB_Changed    =    1
  26. LIBB_SumUsed    =    2
  27. LIBB_DelExp    =    3
  28.  
  29. LIBF_Summing    =    1<<LIBB_Summing
  30. LIBF_Changed    =    1<<LIBB_Changed
  31. LIBF_SumUsed    =    1<<LIBB_SumUsed
  32. LIBF_DelExp    =    1<<LIBB_DelExp
  33.  
  34. ; Macros
  35.  
  36. INBYTE    MACRO
  37.     dc.b    %11100000,0
  38.     dc.w    \1
  39.     dc.b    \2,0
  40.     ENDM
  41.  
  42. INWORD    MACRO
  43.     dc.b    %11010000,0
  44.     dc.w    \1,\2
  45.     ENDM
  46.  
  47. INLONG    MACRO
  48.     dc.b    %11000000,0
  49.     dc.w    \1
  50.     dc.l    \2
  51.     ENDM
  52.  
  53. ; Library Base Structure
  54.  
  55.     STRUCTURE LibraryStruct,0
  56.     STRUCT    LIB_Node,14
  57.     UBYTE    LIB_Flags
  58.     UBYTE    LIB_Pad
  59.     UWORD    LIB_NegSize
  60.     UWORD    LIB_PosSize
  61.     UWORD    LIB_Version
  62.     UWORD    LIB_Revision
  63.     APTR    LIB_IDString
  64.     ULONG    LIB_Sum
  65.     UWORD    LIB_OpenCnt
  66.  
  67.     LONG    LIB_SegList
  68.     LABEL    LibraryStruct_SIZEOF
  69.  
  70.  
  71.     SECTION    xx.library,CODE
  72.  
  73. START    moveq    #0,d0
  74.     rts
  75. ;------------------------------------------------------------------------------
  76. LIBNAME    dc.b    "apxx.library",0
  77.  
  78. LIBID    dc.b    "xx.library 1.0 (02-February-1995)",0
  79.     even
  80. ;------------------------------------------------------------------------------
  81. ; ROMTAG Structure
  82. ;
  83.  
  84. ROMTAG    dc.w    $4afc            ;ROMTAG Indentifier
  85.     dc.l    romtag
  86.     dc.l    slut
  87.     dc.b    $80            ;Flags
  88.     dc.b    version
  89.     dc.b    $09            ;Type Of Module
  90.     dc.b    $00            ;Initialization Priority
  91.     dc.l    libname
  92.     dc.l    libid
  93.     dc.l    autinit            ;Pointer To AUTOINIT Table
  94. ;------------------------------------------------------------------------------
  95. ; AUTOINIT Table
  96. ;
  97.  
  98. AUTINIT    dc.l    LibraryStruct_SIZEOF    ;Size Of Structure AFTER Base Address
  99.     dc.l    vector            ;Pointer To Vector Table
  100.     dc.l    inittab            ;Pointer To Init Structure
  101.     dc.l    init            ;Pointer To Init Routine
  102. ;------------------------------------------------------------------------------
  103. ; Init Table
  104. ;
  105.  
  106. INITTAB    INBYTE    LN_Type,NT_Library
  107.     INBYTE    LIB_Flags,LIBF_SumUsed!LIBF_Changed
  108.     INWORD    LIB_Version,version
  109.     INWORD    LIB_Revision,revision
  110.     INLONG    LN_Name,libname
  111.     INLONG    LIB_IDString,libid
  112.     dc.l    0
  113. ;------------------------------------------------------------------------------
  114. ; Vector Table
  115. ;
  116.  
  117. VECTOR    dc.w    -1
  118.     dc.w    opnlib-vector,clslib-vector,expunge-vector,extfunc-vector
  119.     dc.w    xx_GetTags-vector
  120.     dc.w    -1
  121. ;------------------------------------------------------------------------------
  122. ; Init Routine
  123. ;
  124.  
  125. INIT    movem.l    d1-d7/a0-a6,-(sp)
  126.     move.l    d0,a4            ;Base Address
  127.     move.l    a0,LIB_SegList(a4)
  128.  
  129.     move.l    a4,d0
  130.     movem.l    (sp)+,d1-d7/a0-a6
  131.     rts
  132. ;------------------------------------------------------------------------------
  133. ; Offset  -6: Open Library
  134. ;
  135.  
  136. OPNLIB    addq.w    #1,LIB_OpenCnt(a6)
  137.     bclr    #LIBB_DelExp,LIB_Flags(a6)
  138.     move.l    a6,d0
  139.     rts
  140. ;------------------------------------------------------------------------------
  141. ; Offset -12: Close Library
  142. ;
  143.  
  144. CLSLIB    moveq    #0,d0
  145.     subq.w    #1,LIB_OpenCnt(a6)
  146.     bne.b    clslibo
  147.     btst    #LIBB_DelExp,LIB_Flags(a6)
  148.     bne.b    expunge
  149. CLSLIBO    rts
  150. ;------------------------------------------------------------------------------
  151. ; Offset -18: Expunge
  152. ;
  153.  
  154. EXPUNGE    movem.l    d1-d7/a0-a6,-(sp)
  155.     move.l    a6,a4
  156.     tst.w    LIB_OpenCnt(a4)
  157.     beq.b    exp1
  158.     bset    #LIBB_DelExp,LIB_Flags(a4)
  159.     moveq    #0,d0
  160.     bra.b    expungo
  161.  
  162. EXP1    move.l    4.w,a6
  163.     move.l    LIB_SegList(a4),d2
  164.     move.l    a4,a1
  165.     jsr    Remove(a6)
  166.  
  167.     move.l    a4,a1
  168.     moveq    #0,d0
  169.     move.w    LIB_NegSize(a4),d0
  170.     sub.l    d0,a1
  171.     add.w    LIB_PosSize(a4),d0
  172.     jsr    FreeMem(a6)
  173.     move.l    d2,d0
  174.  
  175. EXPUNGO    movem.l    (sp)+,d1-d7/a0-a6
  176.     rts
  177. ;------------------------------------------------------------------------------
  178. ; Offset -24: ExtFunc
  179. ;
  180.  
  181. EXTFUNC    moveq    #0,d0
  182.     rts
  183. ;------------------------------------------------------------------------------
  184. SLUT
  185.